<?php

    // 获取从前端传过来的数据
    $username = $_GET['username'];
    $userpwd = $_GET['userpwd'];

    // 连接数据库
    $conn = mysqli_connect('localhost', 'root', 'root', 'praday01');

    // 设置编码
    mysqli_query($conn, "set charset 'utf8'");
    mysqli_query($conn, "set charcter set 'utf8'");

    // 设置sql语句
    $sql = "insert into usermsg (username,pwd) values ('$username','$userpwd')";

    // 执行sql语句
    $res = mysqli_query($conn, $sql);

    if($res){
        // 数据插入成功，进行json编码
        echo json_encode(array(
            "code" => 200,
            "body" => array(
                "msg" => "注册成功"
            )
        ));
    } else {
        echo json_encode(array(
            "code" => "205",
            "body" => array(
                "msg" => "注册失败"
            )
        ));
    }

?>